/**
 * Copyright 2006-2015 handu.com
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.iepacj.thkjava.reuseclass;

public class Car {

	private Engine engine = new Engine();

	private Wheel[] wheels = new Wheel[4];

	private Door left = new Door();

	private Door right = new Door();

	public Car() {
		for (int i = 0; i < 3; i++) {
			wheels[i] = new Wheel();
		}
	}

	public Engine getEngine() {
		return engine;
	}

	public void setEngine(Engine engine) {
		this.engine = engine;
	}

	public Wheel[] getWheels() {
		return wheels;
	}

	public void setWheels(Wheel[] wheels) {
		this.wheels = wheels;
	}

	public Door getLeft() {
		return left;
	}

	public void setLeft(Door left) {
		this.left = left;
	}

	public Door getRight() {
		return right;
	}

	public void setRight(Door right) {
		this.right = right;
	}

	public static void main(String[] args) {
		Car car = new Car();
		car.getLeft().getWindow().rollup();
		car.getWheels()[0].inflate(72);
	}

}

class Engine {

	public void start() {
		System.out.println("engine start");
	}

	public void stop() {
		System.out.println("engine stop");
	}
}

class Wheel {

	public void inflate(int spi) {
		System.out.println("inflate" + spi);
	}

}

class Window {

	public void rollup() {
		System.out.println("rollup");
	}

	public void rolldown() {
		System.out.println("rolldown");
	}
}

class Door {

	private Window window = new Window();

	public void open() {

	}

	public void close() {

	}

	public Window getWindow() {
		return window;
	}

	public void setWindow(Window window) {
		this.window = window;
	}

}
